home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / ultqsrc.zip / COMBAT.QC < prev    next >
Text File  |  1996-10-03  |  13KB  |  398 lines

  1. .float floating;
  2. void() T_MissileTouch;
  3. void() info_player_start;
  4. void(entity targ, entity attacker) ClientObituary;
  5. void() monster_death_use;
  6. void(entity inflictor, entity attacker, float dmg,entity ignore) T_RadiusDamage;
  7.  
  8. float(entity targ, entity inflictor) CanDamage =
  9. {
  10.         if (targ.movetype == MOVETYPE_PUSH)
  11.     {
  12.         traceline(inflictor.origin, 0.5 * (targ.absmin + targ.absmax), TRUE, self);
  13.         if (trace_fraction == 1)
  14.             return TRUE;
  15.         if (trace_ent == targ)
  16.                         return TRUE;
  17.         return FALSE;
  18.     }
  19.     
  20.     traceline(inflictor.origin, targ.origin, TRUE, self);
  21.     if (trace_fraction == 1)
  22.         return TRUE;
  23.     traceline(inflictor.origin, targ.origin + '15 15 0', TRUE, self);
  24.     if (trace_fraction == 1)
  25.         return TRUE;
  26.     traceline(inflictor.origin, targ.origin + '-15 -15 0', TRUE, self);
  27.     if (trace_fraction == 1)
  28.         return TRUE;
  29.     traceline(inflictor.origin, targ.origin + '-15 15 0', TRUE, self);
  30.     if (trace_fraction == 1)
  31.         return TRUE;
  32.     traceline(inflictor.origin, targ.origin + '15 -15 0', TRUE, self);
  33.     if (trace_fraction == 1)
  34.         return TRUE;
  35.  
  36.     return FALSE;
  37. };
  38.  
  39. void(entity targ, entity attacker) Killed =
  40. {
  41.         local entity oself,printo;
  42.         local string printnum;
  43.     oself = self;
  44.     self = targ;
  45.  
  46.         if (self.movetype == MOVETYPE_PUSH || self.movetype == MOVETYPE_NONE)
  47.         {       // doors, triggers, etc
  48.                 self.th_die ();
  49.                 self = oself;
  50.                 return;
  51.         }
  52.     self.takedamage = DAMAGE_NO;
  53.     self.touch = SUB_Null;
  54.  
  55.         if ((self.skin==1&&self.classname!="player")||(self.skin==21&&self.classname=="player"))
  56.                 self.health = -99;
  57.  
  58.         if (pointcontents(self.origin+'0 0 24') < -2 && pointcontents(self.origin+'0 0 24') > -5)
  59.                       DeathBubbles (5);
  60.  
  61.         if (self.charmed && self.classname != "player")
  62.                 {
  63.                 self.controller.charmed = self.controller.charmed - 1;
  64.                 sprint(self.controller,"Your ");
  65.                 sprint(self.controller,self.classname);
  66.                 sprint(self.controller," has been killed!\n");
  67.                 self.charmed = FALSE;
  68.                 }
  69.  
  70.         if ((attacker.classname == "player" || attacker.charmed)&& (self.alive||self.classname=="zombie")&&self.controller!=attacker&&self!=attacker)
  71.                 {
  72.                 if(attacker.classname!="player")
  73.                         printo = attacker.controller;
  74.                 else
  75.                 {
  76.                 printo=attacker;
  77.                 if(attacker.enemy == self)
  78.                         attacker.enemy == world;                
  79.                 }
  80.                 sprint(printo,"Experience points: ");
  81.                 printnum=ftos(printo.exp);
  82.                 sprint(printo,printnum);
  83.                 sprint(printo,"\n");
  84.                 }
  85.  
  86.         if (attacker.charmed&&self.alive&&attacker.classname!="player")
  87.                 {
  88.                 sprint(attacker.controller,"Your ");
  89.                 sprint(attacker.controller,attacker.classname);
  90.                 sprint(attacker.controller," has killed a ");
  91.                 sprint(attacker.controller,self.classname);
  92.                 sprint(attacker.controller,"\n");
  93.                 }
  94.  
  95.     if (self.health < -99)
  96.         self.health = -99;        // don't let sbar look bad if a player
  97.  
  98.         self.enemy = attacker;
  99.  
  100.     if (self.flags & FL_MONSTER)
  101.     {
  102.         killed_monsters = killed_monsters + 1;
  103.         WriteByte (MSG_ALL, SVC_KILLEDMONSTER);
  104.     }
  105.  
  106.         if(self.classname=="player")
  107.                 ClientObituary(self, attacker);
  108.  
  109.     monster_death_use();
  110.         if(self.enemy.classname!="player")
  111.                 self.enemy=self;
  112.         self.th_die();
  113.     self = oself;
  114. };
  115.  
  116. void(entity targ, entity inflictor, entity attacker, float damage) T_Damage=
  117. {
  118.     local    vector    dir;
  119.         local   entity  oldself, swap,printo;
  120.         local   float   save, expplus;
  121.         local   float   take, r;
  122.  
  123.     if (!targ.takedamage)
  124.         return;
  125.  
  126.         if (targ.classname == "player" && targ != attacker&&targ.alive)
  127.                 targ.enemy = attacker;
  128.  
  129.         if (targ.protmisstime > time && (inflictor.classname == "rocket" || inflictor.classname == "grenade" || inflictor.classname=="shalmissile" || inflictor.classname=="homespread" || inflictor.classname=="spreadrocket" || inflictor.classname=="homerocket"))
  130.                 {
  131.                 T_RadiusDamage(inflictor, attacker, damage, targ);
  132.                 return;
  133.                 }
  134.  
  135.   if (targ.axhitme != 1)
  136.   {
  137.         if (targ.reflecttime > time && inflictor == attacker && ((attacker.classname == "player"&&attacker.dog_time<time) || attacker.classname == "grunt"))
  138.                 if (attacker.reflecttime > time)
  139.                         return;
  140.                 else
  141.                 {
  142.                 r = random();
  143.                 if (r > 0.7)
  144.                         sound (targ,CHAN_WEAPON,"weapons/ric1.wav",1,ATTN_NORM);
  145.                 else if (r > 0.3)
  146.                         sound (targ,CHAN_WEAPON,"weapons/ric2.wav",1,ATTN_NORM);
  147.                 else
  148.                         sound (targ,CHAN_WEAPON,"weapons/ric3.wav",1,ATTN_NORM);
  149.                 swap = attacker;
  150.                 attacker = targ;
  151.                 inflictor = targ;
  152.                 targ = swap;
  153.                 SpawnBlood (targ.origin, targ.origin, damage);
  154.                 }
  155.   }
  156.   if(random()<0.5&&targ.alive&&attacker==inflictor&&((attacker.classname=="player"&&targ.axhitme)||attacker.classname=="knight"||attacker.classname=="hell knight"||attacker.classname=="ogre"||attacker.classname=="fiend"))
  157.           {
  158.           targ.woundmaker=attacker;
  159.           targ.bloodloss = targ.bloodloss + 1;
  160.           }
  161.  
  162.     if (!targ.takedamage)
  163.         return;
  164.     damage_attacker = attacker;
  165.  
  166.         if (attacker.super_damage_finished > time)
  167.         damage = damage * 4;
  168.  
  169.     save = ceil(targ.armortype*damage);
  170.     if (save >= targ.armorvalue)
  171.     {
  172.         save = targ.armorvalue;
  173.         targ.armortype = 0;    // lost all armor
  174.         targ.items = targ.items - (targ.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3));
  175.     }
  176.     
  177.     targ.armorvalue = targ.armorvalue - save;
  178.     take = ceil(damage-save);
  179.  
  180.     if (targ.flags & FL_CLIENT)
  181.     {
  182.         targ.dmg_take = targ.dmg_take + take;
  183.         targ.dmg_save = targ.dmg_save + save;
  184.         targ.dmg_inflictor = inflictor;
  185.     }
  186.         if ((inflictor != world) && (targ.movetype == MOVETYPE_WALK))
  187.     {
  188.         dir = targ.origin - (inflictor.absmin + inflictor.absmax) * 0.5;
  189.         dir = normalize(dir);
  190.         targ.velocity = targ.velocity + dir*damage*8;
  191.     }
  192.     if (targ.flags & FL_GODMODE)
  193.         return;
  194.  
  195.     if (targ.invincible_finished >= time)
  196.     {
  197.         if (self.invincible_sound < time)
  198.         {
  199.             sound (targ, CHAN_ITEM, "items/protect3.wav", 1, ATTN_NORM);
  200.             self.invincible_sound = time + 2;
  201.         }
  202.         return;
  203.     }
  204.  
  205.         if ((teamplay == 1) && (targ.team > 0)&&(targ.team == attacker.team))
  206.         return;
  207.     targ.health = targ.health - take;
  208.             
  209.         if (inflictor.classname == "throwaxe")
  210.         {
  211.                 if (targ.active != 2)
  212.                         sound (targ, CHAN_WEAPON, "zombie/z_miss.wav", 1, ATTN_NORM);
  213.                 else
  214.                 {
  215.                 r = random();
  216.                 if (targ.health<=0)
  217.                         sound (targ,CHAN_WEAPON,"weapons/taxhit1.wav",1,ATTN_NORM);
  218.                 else if (r > 0.4)
  219.                         sound (targ,CHAN_WEAPON,"weapons/taxhit2.wav",1,ATTN_NORM);
  220.                 else
  221.                         sound (targ,CHAN_WEAPON,"weapons/taxhit3.wav",1,ATTN_NORM);
  222.                 }
  223.         }
  224.  
  225.         if ((attacker.classname == "player"||attacker.charmed) && (targ.alive||targ.classname=="zombie") && targ.controller != attacker)
  226.         {
  227.                if (targ.health <= 0)
  228.                        expplus = take + targ.health;
  229.                else if(targ.classname != "zombie")
  230.                        expplus = take;
  231.                else expplus = 0;
  232.                if(attacker.classname!="player")
  233.                        printo=attacker.controller;
  234.                else printo=attacker;
  235.                printo.exp = printo.exp + expplus*skill;
  236.         }
  237.  
  238.         if (inflictor.classname == "spell")
  239.                 inflictor.mass = inflictor.mass + take;
  240.  
  241.     if (targ.health <= 0)
  242.     {
  243.                 if ((attacker.classname == "player"||attacker.charmed) && (targ.alive)&&targ.controller!=attacker)
  244.                         {
  245.                         if(attacker.classname!="player")
  246.                                 printo=attacker.controller;
  247.                         else printo=attacker;
  248.                         printo.exp = printo.exp + expplus*skill*3;
  249.                         }
  250.                 Killed (targ, attacker);
  251.     }
  252.         else
  253.         {
  254.         if (pointcontents(self.origin) < -2 && pointcontents(self.origin) > -5)
  255.               if (random () < 0.2)
  256.                       DeathBubbles (3);
  257.  
  258.     oldself = self;
  259.     self = targ;
  260.  
  261.         if ((self.flags & FL_MONSTER) && attacker != world && self.skin == 0)
  262.     {
  263.         if (self != attacker && attacker != self.enemy)
  264.         {
  265.             if ( (self.classname != attacker.classname) 
  266.                         || (self.classname == "grunt") || (attacker.charmed && (attacker.controller != self.controller)))
  267.             {
  268.                 if (self.enemy.classname == "player")
  269.                     self.oldenemy = self.enemy;
  270.                 self.enemy = attacker;
  271.                 FoundTarget ();
  272.             }
  273.         }
  274.     }
  275.  
  276.         if(self.skin==0||(self.classname=="player"&&self.skin!=25))
  277.         if(self.th_pain)
  278.     {
  279.         self.th_pain (attacker, take);
  280.         if (skill == 3)
  281.             self.pain_finished = time + 5;        
  282.     }
  283.  
  284.     self = oldself;
  285.         }
  286. };
  287.  
  288. void(entity inflictor, entity attacker, float damage, entity ignore) T_RadiusDamage =
  289. {
  290.         local   float   points;
  291.         local   entity  head;
  292.     local    vector    org;
  293.  
  294.         head = findradius(inflictor.origin, damage + 40);
  295.     
  296.     while (head)
  297.     {
  298.                 if (head != ignore && head.protmisstime < time)
  299.         {
  300.             if (head.takedamage)
  301.             {
  302.                                 if (head.classname == "player" && head != attacker)
  303.                                         head.enemy = attacker;
  304.                 org = head.origin + (head.mins + head.maxs)*0.5;
  305.                 points = 0.5*vlen (inflictor.origin - org);
  306.                 if (points < 0)
  307.                     points = 0;
  308.                 points = damage - points;
  309.                 if (head == attacker)
  310.                     points = points * 0.5;
  311.                 if (points > 0)
  312.                 {
  313.                     if (CanDamage (head, inflictor))
  314.                     {    // shambler takes half damage from all explosions
  315.                                                 if (head.classname == "shambler")                                        
  316.                                                         points = points * 0.5;
  317.                                                 T_Damage (head, inflictor, attacker, points);
  318.                                         }
  319.                 }
  320.             }
  321.         }
  322.         head = head.chain;
  323.     }
  324. };
  325. void(entity inflictor, entity attacker, entity ignore) T_RadiusDamageWater =
  326. {
  327.         local   float   points;
  328.         local   entity  head;
  329.     local    vector    org;
  330.  
  331.         head = findradius(inflictor.origin, 666);
  332.     
  333.     while (head)
  334.     {
  335.         if (head != ignore)
  336.         {
  337.             if (head.takedamage)
  338.             {
  339.                                 if (pointcontents(head.origin) == CONTENT_WATER || pointcontents(head.origin) == CONTENT_SLIME || head.floating) //  visible(inflictor)?
  340.                                 {
  341.                                 if (head.classname == "player" && head != attacker)
  342.                                         head.enemy = attacker;
  343.                                 org = head.origin + (head.mins + head.maxs)*0.5;
  344.                 points = 0.5*vlen (inflictor.origin - org);
  345.                 if (points < 0)
  346.                                         points = 1;
  347.                                 points = 666/points;
  348.                                 if (points < 1)
  349.                                         points = 0;
  350.                 if (points > 0)
  351.                 {
  352.                                         if (head.classname != "shambler")                                        
  353.                                         {       // shambler takes no damage from lightning in water
  354.                                                 if (CanDamage (head, inflictor))
  355.                                                         sprint (attacker,"Zapping");
  356.                                                         sprint (attacker,head.classname);
  357.                                                         sprint (attacker,"\n");
  358.                                                         T_Damage (head, inflictor, attacker, points);
  359.                     }
  360.                 }
  361.                                 }
  362.             }
  363.         }
  364.         head = head.chain;
  365.     }
  366. };
  367. void(entity attacker, float damage) T_BeamDamage =
  368. {
  369.     local    float     points;
  370.     local    entity    head;
  371.     
  372.     head = findradius(attacker.origin, damage+40);
  373.     
  374.     while (head)
  375.     {
  376.         if (head.takedamage)
  377.         {
  378.             points = 0.5*vlen (attacker.origin - head.origin);
  379.             if (points < 0)
  380.                 points = 0;
  381.             points = damage - points;
  382.             if (head == attacker)
  383.                 points = points * 0.5;
  384.             if (points > 0)
  385.             {
  386.                 if (CanDamage (head, attacker))
  387.                 {
  388.                                         if (head.classname == "shambler")                                        
  389.                         T_Damage (head, attacker, attacker, points*0.5);
  390.                     else
  391.                         T_Damage (head, attacker, attacker, points);
  392.                 }
  393.             }
  394.         }
  395.         head = head.chain;
  396.     }
  397. };
  398.